package liuyang.bigeventserver.common.exception;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author liuyang(wx)
 * @since 2022/5/16
 */
@Getter
@AllArgsConstructor
public enum ErrorEnum {
    ServerError(500, "服务器内部错误")
    , MethodNotSupported(80403, "没有该方法")
    , NoResourceFound(80404, "请求资源不存在")
    , MediaTypeNotAcceptable(80500, "请求了不支持的内容协商类型")
    , HttpMediaTypeNotSupported(80501, "媒体类型不支持")// 202403081115 用@RequestBody接收前端发送x-www-form-urlencoded类型数据 Content-Type 'application/x-www-form-urlencoded;charset=UTF-8' is not supported
    , MethodArgumentNotValid(80888, "参数校验失败")
    , HttpMessageNotReadable(80889, "参数转换异常，请检查JSON格式")
    , HandlerMethodValidationException(80890, "参数校验失败")// @URL
    , JwtTokenExpired(80600, "JWT令牌过期")
    , ConstraintViolation(80889, "参数校验失败 @Pattern")
    , DuplicateKey(80501, "违反唯一约束");

    private int code;
    private String msg;

    // 测试一下
    public static void main(String[] args) {
        System.out.println(ErrorEnum.MethodArgumentNotValid.getCode());
        System.out.println(ErrorEnum.MethodArgumentNotValid.getMsg());
        System.out.println(ErrorEnum.MethodArgumentNotValid.ordinal());
        System.out.println(ErrorEnum.MethodArgumentNotValid.name());
    }
}
